package top.continew.admin.controller.business;

import cn.shengchao.examstar.rpc.base.PageResult;
import cn.shengchao.examstar.rpc.distribute.bi.DistributeNodeBI;
import cn.shengchao.examstar.rpc.distribute.req.DistributorQueryPage;
import cn.shengchao.examstar.rpc.distribute.req.DistributorStudentQueryPage;
import cn.shengchao.examstar.rpc.distribute.resp.DistributorRespEntity;
import cn.shengchao.examstar.rpc.distribute.resp.DistributorStudentEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "分销商")
@RestController
@RequiredArgsConstructor
@RequestMapping("/distributor")
public class DistributorController {

    @DubboReference
    private DistributeNodeBI distributeNodeBI;

    @GetMapping
    @Operation(description = "分销商列表", summary = "分销商列表")
    public PageResult<DistributorRespEntity> getDistributorList(DistributorQueryPage distributorQueryPage) {
        return distributeNodeBI.queryDistributorPageResult(distributorQueryPage);
    }

    @GetMapping("{id}/student")
    @Operation(description = "分销商学员", summary = "分销商学员")
    public PageResult<DistributorStudentEntity> getDistributorStudentList(@PathVariable  Long id, DistributorStudentQueryPage distributorQueryPage) {
        distributorQueryPage.setDistributorId(id);
        return distributeNodeBI.queryDistributorStudentPageResult(distributorQueryPage);
    }

}
